home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / croutes.zip / CURSOR.C < prev    next >
Text File  |  1984-04-05  |  2KB  |  55 lines

  1. /*                         *** cursor.c ***                          */
  2. /*                                                                   */
  3. /* IBM - PC microsoft "C"                                            */
  4. /*                                                                   */
  5. /* Function to move the cursor to a specific r,c co-ordinate.        */
  6. /*                                                                   */
  7. /* Written by L. Cuthbertson, March 1984.                            */
  8. /*                                                                   */
  9. /*********************************************************************/
  10. /*                                                                   */
  11.  
  12. #define NULL    '\000'
  13. #define POUND    '#'
  14.  
  15. cursor(r,c)
  16. int r,c;
  17. {
  18.     extern char CUP[];
  19.     char row[3],col[4],command[20];
  20.     int i,inpos,outpos;
  21.  
  22.     /* initialize screen controls */
  23.     scrinit();
  24.  
  25.     /* decode integer co-ordinates */
  26.     sprintf(row,"%d",r);
  27.     sprintf(col,"%d",c);
  28.  
  29.     /* build control sequence */
  30.     inpos = 0;    /* position in control line */
  31.     outpos = 0;    /* position in command line */
  32.  
  33.     while (CUP[inpos] != POUND)
  34.         command[outpos++] = CUP[inpos++];
  35.  
  36.     for (i=0;row[i] != NULL;i++)
  37.         command[outpos++] = row[i];
  38.  
  39.     inpos++;
  40.     while(CUP[inpos] != POUND)
  41.         command[outpos++] = CUP[inpos++];
  42.  
  43.     for (i=0;col[i] != NULL;i++)
  44.         command[outpos++] = col[i];
  45.  
  46.     inpos++;
  47.     while(CUP[inpos] != NULL)
  48.         command[outpos++] = CUP[inpos++];
  49.  
  50.     command[outpos] = NULL;
  51.  
  52.     /* write command to screen */
  53.     writes(command);
  54. }
  55.